package com.example;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@SpringBootApplication
@Controller
@ServletComponentScan
@EnableCaching
public class DemoApplication {
	private static Logger logger = LogManager.getLogger("testme");

	@Autowired
	private MyBean mybean;

	@Autowired  
    DemoService demoService;  
	 
//	@Resource
//    RedisTemplate<String,String> redisTemplate;

	@RequestMapping("/hello2")
	@ResponseBody	
	public String greeting() {
		SpotMedia media = demoService.findMedia();
		String ret=media.getName();
		return ret;
	}

	@RequestMapping("/test")
	public String hello(Model model) {		
		logger.info("test url");
		System.out.println("mybean name:" + mybean.name);
		model.addAttribute("str", "mybean name:" + mybean.name);

		return "hello";
	}

	public static void main(String[] args) {
		SpringApplication.run(DemoApplication.class, args);
	}
}
